/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import Entidades.ResourceEnt;
import Entidades.TemaEnt;
import Utilidades.Conexion;
import Utilidades.Constantes;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author usuario
 */
public class ResourcesDAO {
    
            Conexion con;
            Connection connect;
            
   public List<ResourceEnt> busquedaResources() throws SQLException{
    
        List<ResourceEnt>  lstResource= new ArrayList<ResourceEnt>();
        ResourceEnt resourceEnt;
        con = new Conexion();
        connect = con.getCon();
        
        try {
            
            PreparedStatement st = connect.prepareStatement(Constantes.LISTAR_RESOURCES);
            
            ResultSet rs = st.executeQuery();
            
            if(rs != null){
                while (rs.next()) {
                    
                    resourceEnt = new ResourceEnt();
                    resourceEnt.setClave(rs.getString("CLAVE"));
                    resourceEnt.setValor(rs.getString("VALOR"));
                    lstResource.add(resourceEnt);
                }
            }
            connect.close();
        } catch (SQLException ex) {
            Logger.getLogger(UsuarioDAO.class.getName()).log(Level.SEVERE, null, ex);
            connect.close();
        }
        
        return lstResource;
    }
    
}
